<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>

    <script>
        window.onload = function() {
            var btn = document.getElementById("btn1");
            btn.onclick = function() {
                alert("按钮单击了");
            }
        }
    </script>
  </head>
  <body onload="ready()">
    <button id="btn1">按钮</button>
  </body>
</html>
